export function validateInput(length = 20, label = '输入框') {
    return {
        trigger: "blur",
        validator: (rule:any, value:string, callback:any) => {
            if (value && value.length > length) {
                callback(`${label}最大限制输入${length}字符`);
            } else {
                callback()
            }
        },
    }
}
//格式化文件大小
export function getSizeView(size:number) {
    if (!size) return "0K";
    const num = 1024.0;
    if (size < num) {
        return `${size}B`;
    }
    if (size < Math.pow(num, 2)) {
        return `${(size / num).toFixed(2)}K`;
    }
    if (size < Math.pow(num, 3)) {
        return `${(size / Math.pow(num, 2)).toFixed(2)}M`;
    }
    if (size < Math.pow(num, 4)) {
        return `${(size / Math.pow(num, 3)).toFixed(2)}G`;
    }
    return `${(size / Math.pow(num, 4)).toFixed(2)}T`;
}
/**
 * @param {string} path
 * @returns {Boolean}
 */
export function isExternal(path: string) {
    return /^(https?:|mailto:|tel:)/.test(path)
}